package ru.study.jdbc.entity;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;

import ru.study.jdbc.orm.IOrm;
import ru.study.jdbc.orm.StudentOrm;

public class Student implements AbstractEntity {
	private Long id;
	private String firstName;
	private String middleName;
	private String lastName;	
	
	public Student() {};
	
	public Student(String firstName, String middleName, String lastName) {		
		this.id =  (long) new Random().nextInt(50000);
		this.firstName = firstName;
		this.middleName = middleName;
		this.lastName = lastName;				
	}
	public Student (ResultSet rs) throws Exception {		
		setId(rs.getLong("student_id"));
		setFirstName(rs.getString("firstName"));
		setLastName(rs.getString("surName"));
		setMiddleName(rs.getString("patronymic"));
	}

	@Override
	public Long getId() {return id;	}

	@Override
	public IOrm getOrmDescription() {
		return StudentOrm.getInstance();
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getMiddleName() {
		return middleName;
	}

	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	
	public void setId(Long id) {
		this.id = id;
	}

	@Override
	public String toString() {
		return getClass().getSimpleName()+ " id="+id+", "+lastName +", "+ firstName+" ," +middleName ;
	}
	
}

